package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
*/import org.springframework.stereotype.Component;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.IndustryDao;
import com.hy.erp.inventory.dao.interfaces.IIndustryDao;
import com.hy.erp.inventory.pojo.Industry;
import com.hy.erp.inventory.pojo.interfaces.IIndustry;
import com.hy.erp.inventory.service.interfaces.IIndustryService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:18:29</li>
 * <li>类型名称：IndustryService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@ Name ( "industryService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless
*/
@Component("industryService")
public class IndustryService extends AbstractBusinessService < IndustryDao > implements IIndustryService{

	
	private IIndustryDao industryDao=null;
	

	@Resource(name="industryDao")
	public void setEconomicTypeDao(IIndustryDao industryDao) {
		this.industryDao = industryDao;
	}
	
	@ Override
	public String[] addIndustry (
	                    			Object[] industrys )
	{
		if ( null == industrys)
		{
			return null ;
		}
		
		else
		{

			//IIndustryDao industryDao =
			//                       ( IIndustryDao ) this
			//                                          .getDao ( IIndustry.class ) ;

			Industry[] industryss=new Industry[industrys.length];
						for(int i=0;i<industrys.length;i++)
						{
							Industry industrys2=( Industry ) industrys[i];
							industryss[i]=industrys2;
						}
						return industryDao
						                .persist ( industryss ) ;
		
		}
	}

	@ Override
	public boolean modifyIndustry (
									Industry industry )
	{






		if ( ( null == industry )
			     || ( null == industry
			                                .getIdentifier ( ) )
			     || ( industry
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{

			//	IIndustryDao industryDao =
             //       ( IIndustryDao ) this
             //                          .getDao ( IIndustry.class ) ;

		
					
				if ( null == industryDao )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return (industryDao
				                  .merge ( industry ) != null ) ;
			}
		
	
	
	
	
	
	
	}

	@ Override
	public Integer removeIndustry (
									String [ ] industryIds )
	{






		if ( ( null == industryIds)
			     || ( industryIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{



			//	IIndustryDao industryDao =
            //        ( IIndustryDao ) this
             //                          .getDao ( IIndustry.class ) ;


		

				return industryDao
				                .remove ( industryIds ) ;
			}
	
	
	
	
	
	
	}

	@ Override
	public List < Industry > getIndustryById (
												String [ ] Id )
	{
		if((Id.length!=0)||Id!=null)
		{
			//IIndustryDao industryDao =
           //     ( IIndustryDao ) this
          //                         .getDao ( IIndustry.class ) ;
			industryDao.findByIdentifier ( Id );
		}
		return null ;
	}

	@ Override
	public List < Industry > getAllIndustry ( )
	{
	//	IIndustryDao industryDao =
   ////         ( IIndustryDao ) this
    //                           .getDao ( IIndustry.class ) ;
		return industryDao
		                .find ( ) ;
	}

	@ Override
	public List < Industry > getIndustryByQueryName (
														String queryName ,
														Object [ ] args )
	{
	//	IIndustryDao industryDao =
     //       ( IIndustryDao ) this
      //                         .getDao ( IIndustry.class ) ;
		return industryDao.findByNamedQuery ( queryName , args ) ;
	}

	@ Override
	public String [ ] modifyIndustry (
										Object [ ] industrys )
	{

		if ( null == industrys)
		{
			return null ;
		}
		
		else
		{

	//		IIndustryDao industryDao =
	//		                       ( IIndustryDao ) this
	//		                                          .getDao ( IIndustry.class ) ;

			Industry[] industryss=new Industry[industrys.length];
						for(int i=0;i<industrys.length;i++)
						{
							Industry industrys2=( Industry ) industrys[i];
							industryss[i]=industrys2;
						}
						return industryDao
						                .merge  ( industryss ) ;
		
		}
	
	}


}
